package gomz.pres;

import gomz.pres.admin.GUIAAccount;
import gomz.pres.admin.GUIACategoryadministration;
import gomz.pres.admin.GUIAExport;
import gomz.pres.admin.GUIAHexagramadministration;
import gomz.pres.admin.GUIAImport;
import gomz.pres.admin.GUIAUseradministration;
import gomz.pres.admin.MVerwaltung;
import gomz.pres.question.GUIQHexagram;
import gomz.pres.question.GUIQOverview;
import gomz.pres.question.GUIQQuestion;
import gomz.pres.question.MQuestion;

import java.awt.Color;
import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;

/**
 * Diese Klasse erstellt die Menue- und Iconleiste, Statusleiste und stellt die
 * wichtigsten Komponenten fuer das GUI zur Verfuegung.
 * 
 * @author Dilji
 */

public class GUIMain extends JFrame {

	// Main Panel
	private JPanel plMain;

	// Allgemeiner Abstand zum formatieren
	private final static int ABSTAND = 15;

	// Allgemeine Variabeln fuer das ganze Programm
	private final static int btHeight = 30;
	private final static int btWidth = 140;
	private final static int scrollSpeed = 15;
	private final static Font titleFont = new Font("Arial Black", Font.BOLD, 20);
	private final static Color titleBlue = new Color(0, 151, 219);
	private final static Color bgBlue = new Color(219, 234, 242);
	private final static LineBorder borderColor = new LineBorder(new Color(173,
			200, 241));
	private final static EmptyBorder borderInGap = new EmptyBorder(2, 10, 2, 10);
	private final static EmptyBorder borderInGapScrollPane = new EmptyBorder(2,
			10, 2, 0);
	private final static int tfHeight = 25;
	private final static Color fontColorInactive = titleBlue;

	// tabbs als klassen fuer Question
	private GUIQOverview tabOverview;
	private GUIQQuestion tabQuestion;
	private GUIQHexagram tabKonhex;
	private GUIQHexagram tabPerhex;
	private GUIQHexagram tabKomhex;
	private GUIQHexagram tabWenhex;
	private GUIQHexagram tabNukhex;
	private GUIQHexagram tabFuxhex;
	private GUIQHexagram tabLinhex;

	// tabbs als klassen fuer Administration
	private GUIAAccount tabAccount;
	private GUIAUseradministration tabUseradministration;
	private GUIACategoryadministration tabCategoryadministration;
	private GUIAHexagramadministration tabHexagramadministration;
	private GUIAImport tabImport;
	private GUIAExport tabExport;

	// all the variables for menuBar
	private JMenuBar menuBar;
	private JMenu mFile;
	private JMenuItem miHome;
	private JMenuItem miAdmin;
	private JMenuItem miOpen;
	private JMenuItem miSave;
	private JMenuItem miNewQuestion;
	private JMenuItem miClose;
	private JMenu mEdit;
	private JMenuItem miDelete;
	private JMenu mHelp;
	private JMenuItem miHelp;
	private JMenuItem miInfo;
	private JButton btOkInfo;

	// all the variables for main panels
	private JPanel mainCenter;
	private JPanel viewQuestion;
	private JPanel viewAdministration;
	private JTabbedPane tabbsQuestion;
	private JTabbedPane tabbsAdministration;

	// all the variables for toolBar
	private Integer iconSize;
	private JToolBar toolBar;
	private Box iconsBox;

	private ImageIcon imgHome;
	private ImageIcon imgHomeActive;
	private JButton btIconHome;
	private ImageIcon imgAdministration;
	private ImageIcon imgAdministrationActive;
	private JButton btIconAdministration;
	private ImageIcon imgNew;
	private ImageIcon imgNewActive;
	private JButton btIconNew;
	private ImageIcon imgEdit;
	private ImageIcon imgEditActive;
	private JButton btIconEdit;
	private ImageIcon imgSave;
	private ImageIcon imgSaveActive;
	private JButton btIconSave;
	private ImageIcon imgDelete;
	private ImageIcon imgDeleteActive;
	private JButton btIconDelete;
	private ImageIcon imgSearch;
	private ImageIcon imgSearchActive;
	private ImageIcon imgReset;
	private ImageIcon imgResetActive;

	
	private JDialog guiMini;

	// all the variables for statusBar
	private JPanel plStatus;
	private JLabel lbStatus;
	private JLabel lbUserName;

	/**
	 * Konstruktor fuer das UI des GUI-Main.
	 * @param modelQ Methoden fuer die Home-Ansicht (Fragen)
	 * @param modelV Methoden fuer die Verwaltung-Ansicht
	 */
	protected GUIMain(MQuestion modelQ, MVerwaltung modelV) {

		// Fenster erstellen
		try {
			this.setTitle("Yi Ching");
			this.setPreferredSize(new Dimension(1200, 800));
			this.setMinimumSize(new Dimension(660, 400));
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			this.setIconImage(Toolkit.getDefaultToolkit().getImage(GUIMain.class.getResource("/gomz/img/logo.png")));
		} catch (Exception e) {
			e.printStackTrace();
		}

		// Windows Look&Feel setzten
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}

		// Aussehen fuer OptionPane setzten
		UIManager UI = new UIManager();
		UI.put("OptionPane.background", GUIMain.getBgblue());
		UI.put("Panel.background", GUIMain.getBgblue());

		// Main Panel
		this.plMain = new JPanel();
		this.getContentPane().add(plMain, BorderLayout.CENTER);

		// neues objekt der tabbs fuer Question
		this.tabOverview = new GUIQOverview();
		this.tabQuestion = new GUIQQuestion();
		this.tabKonhex = new GUIQHexagram("Kontexthexagramm");
		this.tabPerhex = new GUIQHexagram("Perspektivhexagramm");
		this.tabKomhex = new GUIQHexagram("Komplement\u00e4rhexagramm");
		this.tabWenhex = new GUIQHexagram("Wendehexagramm");
		this.tabNukhex = new GUIQHexagram("Nuklear Hexagramm");
		this.tabFuxhex = new GUIQHexagram("Fuxi Hexagramm");
		this.tabLinhex = new GUIQHexagram("Linienhexagramme");

		// neues objekt der tabbs fuer Administration
		this.tabAccount = new GUIAAccount(false);
		this.tabUseradministration = new GUIAUseradministration();
		this.tabCategoryadministration = new GUIACategoryadministration();
		this.tabHexagramadministration = new GUIAHexagramadministration();
		this.tabImport = new GUIAImport();
		this.tabExport = new GUIAExport();

		// ********************************************************************************
		// MENUBAR
		// ********************************************************************************

		// initialize the components for menuBar
		this.menuBar = new JMenuBar();
		this.mFile = new JMenu("Datei");
		this.miHome = new JMenuItem("Home");
		this.miAdmin = new JMenuItem("Verwaltung");
		this.miOpen = new JMenuItem("Editieren");
		this.miSave = new JMenuItem("Speichern");
		this.miNewQuestion = new JMenuItem("Neue Frage");
		this.miClose = new JMenuItem("Schliessen");
		this.mEdit = new JMenu("Bearbeiten");
		this.miDelete = new JMenuItem("L\u00f6schen");
		this.mHelp = new JMenu("Hilfe");
		this.miHelp = new JMenuItem("Hilfe");
		this.miInfo = new JMenuItem("Info");

		// set menuBar and add components
		this.setJMenuBar(menuBar);
		// Datei*******************
		this.menuBar.add(mFile);
		this.mFile.add(miHome);
		this.mFile.add(miAdmin);
		this.mFile.addSeparator();
		this.mFile.add(miNewQuestion);
		this.mFile.add(miClose);
		// Bearbeiten**************
		this.mEdit.add(miNewQuestion);
		this.mEdit.addSeparator();
		this.menuBar.add(mEdit);
		this.mEdit.add(miOpen);
		this.mEdit.add(miSave);
		this.mEdit.add(miDelete);
		// Hilfe*******************
		this.menuBar.add(mHelp);
		this.mHelp.add(miHelp);
		this.mHelp.addSeparator();
		this.mHelp.add(miInfo);

		// ********************************************************************************
		// MAIN PANELS
		// ********************************************************************************

		// initialize the main panels, add to scrollpane and set position
		this.tabbsQuestion = new JTabbedPane(JTabbedPane.TOP);
		this.tabbsQuestion.setBorder(new EmptyBorder(0, 0, 0, 0));
		this.viewQuestion = new JPanel();
		this.viewQuestion.setBackground(bgBlue);
		this.viewQuestion.setLayout(new BorderLayout());
		this.viewQuestion.add(tabbsQuestion, BorderLayout.CENTER);

		this.tabbsAdministration = new JTabbedPane(JTabbedPane.TOP);
		this.tabbsAdministration.setBorder(new EmptyBorder(0, 0, 0, 0));
		this.viewAdministration = new JPanel();
		this.viewAdministration.setBackground(bgBlue);
		this.viewAdministration.setLayout(new BorderLayout());
		this.viewAdministration.add(tabbsAdministration, BorderLayout.CENTER);

		// add main panels to tabbedPane (tabbs) for Question
		// listen aus model laden
		modelQ.setQuestionCoresUsed(modelQ.getQuestionCoresAll());
		this.tabbsQuestion.addTab("\u00dcbersicht", tabOverview.getTab(modelQ.getCategoryList(),modelQ.getQuestionList()));
		this.tabbsQuestion.addTab("Fragestellung", tabQuestion.getTab(modelQ.getCategoryList()));
		this.tabbsQuestion.addTab("Kontexthexagramm", tabKonhex.getTab(true));
		this.tabbsQuestion.addTab("Perspektivhexagramm", tabPerhex.getTab(true));
		this.tabbsQuestion.addTab("Komplement\u00e4rhexagramm", tabKomhex.getTab(true));
		this.tabbsQuestion.addTab("Wendehexagramm", tabWenhex.getTab(true));
		this.tabbsQuestion.addTab("Nuklear Hexagramm", tabNukhex.getTab(true));
		this.tabbsQuestion.addTab("Fuxi Hexagramm", tabFuxhex.getTab(true));
		this.tabbsQuestion.addTab("Linienhexagramme", tabLinhex.getTab(false));

		// add main panels to tabbedPane (tabbs) for Administration
		// listen aus model laden
		this.tabbsAdministration.addTab("Accountdaten", tabAccount.getTab());
		this.tabbsAdministration.addTab("Benutzerverwaltung", tabUseradministration.getTab(modelV.getUserList()));
		this.tabbsAdministration.addTab("Kategorienverwaltung", tabCategoryadministration.getTab(modelV.getCategoryList()));
		this.tabbsAdministration.addTab("Hexagrammverwaltung", tabHexagramadministration.getTab(modelV.getHexagramList()));
		this.tabbsAdministration.addTab("Export", tabExport.getTab(modelV.getCategoryList(), modelV.getQuestionList()));
		// this.tabbsAdministration.addTab("Export",
		// tabExport.getTab(modelV.getCategoryList(),
		// modelV.getQuestionList()));
		this.tabbsAdministration.addTab("Import", tabImport.getTab(modelV.getCategoryList()));

		// set background of main panels
		this.plMain.setBackground(Color.WHITE);
		this.tabbsQuestion.setBackground(Color.black);
		this.tabbsAdministration.setBackground(Color.WHITE);

		// ********************************************************************************
		// ICONBAR (NORTH)
		// ********************************************************************************

		// size of all icons
		this.iconSize = 32;

		// initialize the components of iconsBar
		this.toolBar = new JToolBar();
		this.toolBar.setRollover(true);
		this.toolBar.setBackground(bgBlue);
		this.toolBar.setPreferredSize(new Dimension(0, (this.iconSize + GUIMain.ABSTAND)));
		this.toolBar.setBorder(new EmptyBorder(10, 0, 0, GUIMain.getAbstand()));

		// initialize the components for icons and format buttons
		this.imgHome = new ImageIcon(getClass().getResource("/gomz/img/home.png"));
		this.imgHome.setImage(imgHome.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgHomeActive = new ImageIcon(getClass().getResource("/gomz/img/home_active.png"));
		this.imgHomeActive.setImage(imgHomeActive.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.btIconHome = new JButton();
		this.btIconHome.setToolTipText("Home");
		this.btIconHome.setIcon(imgHomeActive);
		this.btIconHome.setPressedIcon(imgHomeActive);
		this.btIconHome.setBackground(null);
		this.btIconHome.setBorder(null);
		this.btIconHome.setBorderPainted(false);
		this.btIconHome.setPreferredSize(new Dimension(this.iconSize, this.iconSize));
		this.btIconHome.setMaximumSize(new Dimension(this.iconSize, this.iconSize));
			// kein background beim klicken des icon
		this.btIconHome.setContentAreaFilled(false);
			// keine dotted line wenn ausgewaehlt
		this.btIconHome.setFocusable(false);

		this.imgAdministration = new ImageIcon(getClass().getResource("/gomz/img/administration.png"));
		this.imgAdministration.setImage(imgAdministration.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgAdministrationActive = new ImageIcon(getClass().getResource("/gomz/img/administration_active.png"));
		this.imgAdministrationActive.setImage(imgAdministrationActive.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.btIconAdministration = new JButton();
		this.btIconAdministration.setToolTipText("Verwaltung");
		this.btIconAdministration.setIcon(imgAdministration);
		this.btIconAdministration.setPressedIcon(imgAdministrationActive);
		this.btIconAdministration.setBackground(null);
		this.btIconAdministration.setBorder(null);
		this.btIconAdministration.setBorderPainted(false);
		this.btIconAdministration.setPreferredSize(new Dimension(this.iconSize,	this.iconSize));
		this.btIconAdministration.setMaximumSize(new Dimension(this.iconSize, this.iconSize));
			// kein background beim klicken des icon
		this.btIconAdministration.setContentAreaFilled(false);
			// keine dotted line wenn ausgewaehlt
		this.btIconAdministration.setFocusable(false);

		this.imgNew = new ImageIcon(getClass().getResource("/gomz/img/new.png"));
		this.imgNew.setImage(imgNew.getImage().getScaledInstance(this.iconSize,	this.iconSize, Image.SCALE_DEFAULT));
		this.imgNewActive = new ImageIcon(getClass().getResource("/gomz/img/new_active.png"));
		this.imgNewActive.setImage(imgNewActive.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.btIconNew = new JButton();
		this.btIconNew.setToolTipText("Neue Frage");
		this.btIconNew.setIcon(imgNew);
		this.btIconNew.setPressedIcon(imgNewActive);
		this.btIconNew.setBackground(null);
		this.btIconNew.setBorder(null);
		this.btIconNew.setBorderPainted(false);
		this.btIconNew.setPreferredSize(new Dimension(this.iconSize,this.iconSize));
		this.btIconNew.setMaximumSize(new Dimension(this.iconSize,this.iconSize));
			// kein background beim klicken des icon
		this.btIconNew.setContentAreaFilled(false);
			// keine dotted line wenn ausgewaehlt
		this.btIconNew.setFocusable(false);

		this.imgEdit = new ImageIcon(getClass().getResource("/gomz/img/edit.png"));
		this.imgEdit.setImage(imgEdit.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgEditActive = new ImageIcon(getClass().getResource("/gomz/img/edit_active.png"));
		this.imgEditActive.setImage(imgEditActive.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.btIconEdit = new JButton();
		this.btIconEdit.setToolTipText("Editieren");
		this.btIconEdit.setIcon(imgEdit);
		this.btIconEdit.setPressedIcon(imgEditActive);
		this.btIconEdit.setBackground(null);
		this.btIconEdit.setBorder(null);
		this.btIconEdit.setBorderPainted(false);
		this.btIconEdit.setPreferredSize(new Dimension(this.iconSize,this.iconSize));
		this.btIconEdit.setMaximumSize(new Dimension(this.iconSize,	this.iconSize));
			// kein background beim klicken des icon
		this.btIconEdit.setContentAreaFilled(false);
			// keine dotted line wenn ausgewaehlt
		this.btIconEdit.setFocusable(false);
		this.btIconEdit.setEnabled(true);

		this.imgSave = new ImageIcon(getClass().getResource("/gomz/img/save.png"));
		this.imgSave.setImage(imgSave.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgSaveActive = new ImageIcon(getClass().getResource("/gomz/img/save_active.png"));
		this.imgSaveActive.setImage(imgSaveActive.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.btIconSave = new JButton();
		this.btIconSave.setToolTipText("Speichern");
		this.btIconSave.setIcon(imgSave);
		this.btIconSave.setPressedIcon(imgSaveActive);
		this.btIconSave.setBackground(null);
		this.btIconSave.setBorder(null);
		this.btIconSave.setBorderPainted(false);
		this.btIconSave.setPreferredSize(new Dimension(this.iconSize,this.iconSize));
		this.btIconSave.setMaximumSize(new Dimension(this.iconSize,	this.iconSize));
			// kein background beim klicken des icon
		this.btIconSave.setContentAreaFilled(false);
			// keine dotted line wenn ausgewaehlt
		this.btIconSave.setFocusable(false);

		this.imgDelete = new ImageIcon(getClass().getResource("/gomz/img/delete.png"));
		this.imgDelete.setImage(imgDelete.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgDeleteActive = new ImageIcon(getClass().getResource("/gomz/img/delete_active.png"));
		this.imgDeleteActive.setImage(imgDeleteActive.getImage().getScaledInstance(this.iconSize, this.iconSize,Image.SCALE_DEFAULT));
		this.btIconDelete = new JButton();
		this.btIconDelete.setToolTipText("L\u00f6schen");
		this.btIconDelete.setIcon(imgDelete);
		this.btIconDelete.setPressedIcon(imgDeleteActive);
		this.btIconDelete.setBackground(null);
		this.btIconDelete.setBorder(null);
		this.btIconDelete.setBorderPainted(false);
		this.btIconDelete.setPreferredSize(new Dimension(this.iconSize,	this.iconSize));
		this.btIconDelete.setMaximumSize(new Dimension(this.iconSize,this.iconSize));
			// kein background beim klicken des icon
		this.btIconDelete.setContentAreaFilled(false);
			// keine dotted line wenn ausgewaehlt
		this.btIconDelete.setFocusable(false);
		
		this.imgReset = new ImageIcon(getClass().getResource("/gomz/img/reset.png"));
		this.imgReset.setImage(imgReset.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgResetActive = new ImageIcon(getClass().getResource("/gomz/img/reset_active.png"));
		this.imgResetActive.setImage(imgResetActive.getImage().getScaledInstance(this.iconSize, this.iconSize,Image.SCALE_DEFAULT));

		this.imgSearch = new ImageIcon(getClass().getResource("/gomz/img/search.png"));
		this.imgSearch.setImage(imgSearch.getImage().getScaledInstance(this.iconSize, this.iconSize, Image.SCALE_DEFAULT));
		this.imgSearchActive = new ImageIcon(getClass().getResource("/gomz/img/search_active.png"));
		this.imgSearchActive.setImage(imgSearchActive.getImage().getScaledInstance(this.iconSize, this.iconSize,Image.SCALE_DEFAULT));
		
		// set icon save on enabled false for first view (Home-Uebersicht)
		this.btIconSave.setEnabled(false);

		// BOX for icons
		this.iconsBox = Box.createHorizontalBox();
		iconsBox.add(Box.createHorizontalStrut((GUIMain.ABSTAND) / 3));
		iconsBox.add(btIconHome);
		iconsBox.add(Box.createHorizontalStrut(GUIMain.ABSTAND));
		iconsBox.add(btIconAdministration);
		iconsBox.add(Box.createHorizontalStrut(GUIMain.ABSTAND));
		iconsBox.add(new JSeparator(SwingConstants.VERTICAL));
		iconsBox.add(Box.createHorizontalStrut(GUIMain.ABSTAND));
		iconsBox.add(btIconNew);
		iconsBox.add(Box.createHorizontalStrut(GUIMain.ABSTAND));
		iconsBox.add(btIconSave);
		iconsBox.add(Box.createHorizontalStrut(GUIMain.ABSTAND));
		iconsBox.add(btIconDelete);
		iconsBox.add(Box.createHorizontalStrut(GUIMain.ABSTAND));
		iconsBox.add(btIconEdit);
		
		// position of components
		this.toolBar.setLayout(new BorderLayout(2, 1));
		this.toolBar.add(iconsBox, BorderLayout.LINE_START);
		
		// toolBar nicht verschiebbar
		this.toolBar.setFloatable(false);

		// ********************************************************************************
		// STATUSBAR (SOUTH)
		// ********************************************************************************

		// initialize the components of statusBar
		this.plStatus = new JPanel();
		this.lbStatus = new JLabel();
		this.lbUserName = new JLabel();

		// set background
		this.plStatus.setBackground(bgBlue);

		// panel bottom/south
		this.lbStatus.setText("Willkommen bei Yi Ching!");

		// position of components
		this.plStatus.setPreferredSize(new Dimension(0, 30));
		this.plStatus.setMaximumSize(new Dimension(0, 30));
		this.plStatus.setBorder(BorderFactory.createEmptyBorder((ABSTAND / 2),
				ABSTAND, (ABSTAND / 2), (ABSTAND * 2)));
		this.plStatus.setLayout(new BorderLayout(2, 1));
		this.plStatus.add(lbStatus, BorderLayout.LINE_START);
		this.plStatus.add(lbUserName, BorderLayout.LINE_END);

		// ********************************************************************************
		// set main LAYOUT
		// ********************************************************************************

		// set only question view on visible
		this.viewQuestion.setVisible(true);
		this.viewAdministration.setVisible(false);

		// add view question to mainCenter
		this.mainCenter = new JPanel();
		this.mainCenter.setLayout(new BorderLayout());
		this.mainCenter.add(viewQuestion, BorderLayout.CENTER);

		this.plMain.setLayout(new BorderLayout());
		this.plMain.add(mainCenter, BorderLayout.CENTER);
		this.plMain.add(toolBar, BorderLayout.NORTH);
		this.plMain.add(plStatus, BorderLayout.SOUTH);

		this.pack();
		this.setVisible(true);

	}
	
	/**
	 * Diese Methode erstellt das UI fuer das Hilfe- und Info-Fenster der Menueleiste.
	 * @param ansicht gibt an, ob Hilfe- oder Info-Ansicht erstllt werden soll
	 */
	public void getGuiMini(String ansicht) {
		this.guiMini = new JDialog(this,ModalityType.APPLICATION_MODAL);
		
		guiMini.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
		JPanel plTitle = new JPanel();
		JPanel plButton = new JPanel();
		JPanel plMiddle = new JPanel();
		String titleWindow = new String();
		String title = new String();
		String text = new String();
		String lbForText = new String();
		
		if(ansicht.equals("help")){
			titleWindow = "Hilfe";
			title = "Hilfe zu Yi Ching";
			text = "Das Yi Jing ist eine Sammlung von Strichzeichnungen und zugeordneten Spr\u00fcchen. " +
					"Es ist der \u00e4lteste der klassischen chinesischen Texte. \n\nUm eine neue Frage zu " +
					"erstellen, klicken Sie auf auf das Symbol 'Neue Frage' oder auf 'Bearbeiten' und 'Neue Frage' .";
			guiMini.setPreferredSize(new Dimension(500, 300));
		} else {
			titleWindow = "Info";
			title = "Yi Ching Programm";
			lbForText = "<html><div style=\"text-align: center;\"><b>Fachhochschule Nordwestschweiz <br>Institut fuer Wirtschaftsinformatik</b><br><br>(c) Edis Dilji, Francis Murillo,<br>Benjamin Schatzmann,<br>Tobias Neuenschwander<br><br>Final version 24.05.2013</html>";
			guiMini.setPreferredSize(new Dimension(300, 300));
		}
		
		// Button OK
		JLabel lbTitle = new JLabel(title);
		JTextArea taTxt = new JTextArea(text);
		JLabel lbTxt = new JLabel(lbForText);
		this.btOkInfo = new JButton("OK");
		this.btOkInfo.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				guiMini.dispose();
			}
		});
		guiMini.getRootPane().setDefaultButton(this.btOkInfo);
		this.btOkInfo.setPreferredSize(new Dimension(GUIMain.getBtWidth(), GUIMain.getBtHeight()));
		this.btOkInfo.setMaximumSize(new Dimension(GUIMain.getBtWidth(), GUIMain.getBtHeight()));

		plButton.add(btOkInfo);
		plTitle.add(lbTitle);
		// true to set formatting
		taTxt.setOpaque(true);
		// user can not edit this JTextArea
		taTxt.setEditable(false);
		// set automatically linewrap
		taTxt.setLineWrap(true);
		// set wrap style word
		taTxt.setWrapStyleWord(true);
		// font
		taTxt.setFont(this.lbUserName.getFont());
		// keine Hintergrundfarbe
		taTxt.setBackground(null);

		lbTitle.setForeground(getTitleblue());
		lbTitle.setFont(getTitlefont());
		plMiddle.add(lbTxt);
		
		// BOX
		Box miniBox = Box.createVerticalBox();
		miniBox.setBorder(new EmptyBorder((getAbstand()*2), getAbstand(), (getAbstand()*2), getAbstand()));
		miniBox.add(plTitle);
		miniBox.add(Box.createVerticalStrut(GUIMain.getAbstand()));
		if(ansicht.equals("help")){miniBox.add(taTxt);} 
		else {miniBox.add(plMiddle);}		
		miniBox.add(Box.createVerticalStrut(GUIMain.getAbstand()));
		miniBox.add(plButton);
		
		guiMini.add(miniBox);

		guiMini.setTitle(titleWindow);
		//gmini.setResizable(false);
		guiMini.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		guiMini.setIconImage(Toolkit.getDefaultToolkit().getImage(GUIMain.class.getResource("/gomz/img/logo.png")));
		// set window at center of screen
		guiMini.setLocationRelativeTo(null);
		guiMini.pack();
		guiMini.setVisible(true);
		guiMini.setResizable(false);
		
	}

	// ********************************************************************************
	// Getters und Setters
	// ********************************************************************************

	public JPanel getMainCenter() {
		return mainCenter;
	}

	public JButton getBtOkInfo() {
		return btOkInfo;
	}

	public void setBtOkInfo(JButton btOkInfo) {
		this.btOkInfo = btOkInfo;
	}

	public void setMainCenter(JPanel mainCenter) {
		this.mainCenter = mainCenter;
	}

	public JPanel getViewQuestion() {
		return viewQuestion;
	}

	public void setViewQuestion(JPanel viewQuestion) {
		this.viewQuestion = viewQuestion;
	}

	public JPanel getViewAdministration() {
		return viewAdministration;
	}

	public void setViewAdministration(JPanel viewAdministration) {
		this.viewAdministration = viewAdministration;
	}

	public JPanel getPlMain() {
		return plMain;
	}

	public void setPlMain(JPanel plMain) {
		this.plMain = plMain;
	}

	public JTabbedPane getTabbsQuestion() {
		return tabbsQuestion;
	}

	public void setTabbsQuestion(JTabbedPane tabbsQuestion) {
		this.tabbsQuestion = tabbsQuestion;
	}

	public JTabbedPane getTabbsAdministration() {
		return tabbsAdministration;
	}

	public void setTabbsAdministration(JTabbedPane tabbsAdministration) {
		this.tabbsAdministration = tabbsAdministration;
	}

	public JButton getBtIconHome() {
		return btIconHome;
	}

	public void setBtIconHome(JButton btIconHome) {
		this.btIconHome = btIconHome;
	}

	public JButton getBtIconAdministration() {
		return btIconAdministration;
	}

	public void setBtIconAdministration(JButton btIconAdministration) {
		this.btIconAdministration = btIconAdministration;
	}

	public JButton getBtIconNew() {
		return btIconNew;
	}

	public void setBtIconNew(JButton btIconNew) {
		this.btIconNew = btIconNew;
	}

	public JButton getBtIconSave() {
		return btIconSave;
	}

	public void setBtIconSave(JButton btIconSave) {
		this.btIconSave = btIconSave;
	}

	public JButton getBtIconDelete() {
		return btIconDelete;
	}

	public void setBtIconDelete(JButton btIconDelete) {
		this.btIconDelete = btIconDelete;
	}

	public GUIQOverview getTabOverview() {
		return tabOverview;
	}

	public GUIQQuestion getTabQuestion() {
		return tabQuestion;
	}

	public GUIQHexagram getTabKonhex() {
		return tabKonhex;
	}

	public GUIQHexagram getTabPerhex() {
		return tabPerhex;
	}

	public GUIQHexagram getTabKomhex() {
		return tabKomhex;
	}

	public GUIQHexagram getTabWenhex() {
		return tabWenhex;
	}

	public GUIQHexagram getTabNukhex() {
		return tabNukhex;
	}

	public GUIQHexagram getTabFuxhex() {
		return tabFuxhex;
	}

	public GUIQHexagram getTabLinhex() {
		return tabLinhex;
	}

	public JLabel getLbStatus() {
		return lbStatus;
	}

	public void setLbStatus(String string) {
		this.lbStatus.setText(string);
	}

	public static int getBtwidth() {
		return btWidth;
	}

	public static int getBtheight() {
		return btHeight;
	}

	public static int getAbstand() {
		return ABSTAND;
	}

	public static int getBtHeight() {
		return btHeight;
	}

	public static int getBtWidth() {
		return btWidth;
	}

	public GUIAAccount getTabAccount() {
		return tabAccount;
	}

	public GUIAUseradministration getTabUseradministration() {
		return tabUseradministration;
	}

	public GUIACategoryadministration getTabCategoryadministration() {
		return tabCategoryadministration;
	}

	public GUIAHexagramadministration getTabHexagramadministration() {
		return tabHexagramadministration;
	}

	public GUIAImport getTabImport() {
		return tabImport;
	}

	public GUIAExport getTabExport() {
		return tabExport;
	}

	public ImageIcon getImgHome() {
		return imgHome;
	}

	public void setImgHome(ImageIcon imgHome) {
		this.imgHome = imgHome;
	}

	public ImageIcon getImgHomeActive() {
		return imgHomeActive;
	}

	public void setImgHomeActive(ImageIcon imgHomeActive) {
		this.imgHomeActive = imgHomeActive;
	}

	public ImageIcon getImgAdministration() {
		return imgAdministration;
	}

	public void setImgAdministration(ImageIcon imgAdministration) {
		this.imgAdministration = imgAdministration;
	}

	public ImageIcon getImgAdministrationActive() {
		return imgAdministrationActive;
	}

	public void setImgAdministrationActive(ImageIcon imgAdministrationActive) {
		this.imgAdministrationActive = imgAdministrationActive;
	}

	public static int getScrollspeed() {
		return scrollSpeed;
	}

	public static Color getTitleblue() {
		return titleBlue;
	}

	public static Font getTitlefont() {
		return titleFont;
	}

	public static Color getBgblue() {
		return bgBlue;
	}

	public static int getTfheight() {
		return tfHeight;
	}

	public static LineBorder getBorderColor() {
		return borderColor;
	}

	public static EmptyBorder getBorderInGap() {
		return borderInGap;
	}

	public static EmptyBorder getBorderInGapScrollPane() {
		return borderInGapScrollPane;
	}

	public static Color getFontcolorinactive() {
		return fontColorInactive;
	}

	public JLabel getLbUserName() {
		return lbUserName;
	}

	public void setLbUserName(String userName) {
		this.lbUserName.setText(userName);
	}

	public JMenuItem getMiHome() {
		return miHome;
	}

	public void setMiHome(JMenuItem miHome) {
		this.miHome = miHome;
	}

	public JMenuItem getMiAdmin() {
		return miAdmin;
	}

	public void setMiAdmin(JMenuItem miAdmin) {
		this.miAdmin = miAdmin;
	}

	public JMenuItem getMiOpen() {
		return miOpen;
	}

	public void setMiOpen(JMenuItem miOpen) {
		this.miOpen = miOpen;
	}

	public JMenuItem getMiSave() {
		return miSave;
	}

	public void setMiSave(JMenuItem miSave) {
		this.miSave = miSave;
	}

	public JMenuItem getMiNewQuestion() {
		return miNewQuestion;
	}

	public void setMiNewQuestion(JMenuItem miNewQuestion) {
		this.miNewQuestion = miNewQuestion;
	}

	public JMenuItem getMiClose() {
		return miClose;
	}

	public void setMiClose(JMenuItem miClose) {
		this.miClose = miClose;
	}

	public JMenuItem getMiDelete() {
		return miDelete;
	}

	public void setMiDelete(JMenuItem miDelete) {
		this.miDelete = miDelete;
	}

	public JMenuItem getMiHelp() {
		return miHelp;
	}

	public void setMiHelp(JMenuItem miHelp) {
		this.miHelp = miHelp;
	}

	public JMenuItem getMiInfo() {
		return miInfo;
	}

	public void setMiInfo(JMenuItem miInfo) {
		this.miInfo = miInfo;
	}

	public Box getIconsBox() {
		return iconsBox;
	}

	public void setIconsBox(Box iconsBox) {
		this.iconsBox = iconsBox;
	}

	public ImageIcon getImgDelete() {
		return imgDelete;
	}

	public void setImgDelete(ImageIcon imgDelete) {
		this.imgDelete = imgDelete;
	}

	public ImageIcon getImgDeleteActive() {
		return imgDeleteActive;
	}

	public void setImgDeleteActive(ImageIcon imgDeleteActive) {
		this.imgDeleteActive = imgDeleteActive;
	}

	public ImageIcon getImgReset() {
		return imgReset;
	}

	public void setImgReset(ImageIcon imgReset) {
		this.imgReset = imgReset;
	}

	public ImageIcon getImgResetActive() {
		return imgResetActive;
	}

	public void setImgResetActive(ImageIcon imgResetActive) {
		this.imgResetActive = imgResetActive;
	}

	public ImageIcon getImgEdit() {
		return imgEdit;
	}

	public void setImgEdit(ImageIcon imgEdit) {
		this.imgEdit = imgEdit;
	}

	public ImageIcon getImgEditActive() {
		return imgEditActive;
	}

	public ImageIcon getImgSearch() {
		return imgSearch;
	}

	public void setImgSearch(ImageIcon imgSearch) {
		this.imgSearch = imgSearch;
	}

	public ImageIcon getImgSearchActive() {
		return imgSearchActive;
	}

	public void setImgSearchActive(ImageIcon imgSearchActive) {
		this.imgSearchActive = imgSearchActive;
	}

	public JButton getBtIconEdit() {
		return btIconEdit;
	}

	public void setBtIconEdit(JButton btIconEdit) {
		this.btIconEdit = btIconEdit;
	}
	
}
